<?
	$c = mysql_connect('localhost','chileesm_lobo','nuhk@HgHTDO]');
	mysql_select_db('chileesm_lobos',$c);

	$rs = mysql_query( 'SELECT id FROM actividad WHERE lobo=1 AND estado=0 ORDER BY ID ASC LIMIT 0,1 ' , $c );
	while($r = mysql_fetch_assoc($rs)) {
		mysql_query( 'UPDATE actividad SET estado=1 WHERE lobo=1 AND estado=0 AND id='.$r['id'], $c );
	}
	mysql_free_result($rs);
	
	$rs = mysql_query( 'SELECT id FROM actividad WHERE lobo=2 AND estado=0 ORDER BY ID ASC LIMIT 0,1 ' , $c );
	while($r = mysql_fetch_assoc($rs)) {
		mysql_query( 'UPDATE actividad SET estado=1 WHERE lobo=2 AND estado=0 AND id='.$r['id'], $c );
	}
	mysql_free_result($rs);

	$rs = mysql_query( 'SELECT id FROM actividad WHERE lobo=3 AND estado=0 ORDER BY ID ASC LIMIT 0,1 ' , $c );
	while($r = mysql_fetch_assoc($rs)) {
		mysql_query( 'UPDATE actividad SET estado=1 WHERE lobo=3 AND estado=0 AND id='.$r['id'], $c );
	}
	mysql_free_result($rs);

	$rs = mysql_query( 'SELECT id FROM actividad WHERE lobo=4 AND estado=0 ORDER BY ID ASC LIMIT 0,1 ' , $c );
	while($r = mysql_fetch_assoc($rs)) {
		mysql_query( 'UPDATE actividad SET estado=1 WHERE lobo=4 AND estado=0 AND id='.$r['id'], $c );
	}
	mysql_free_result($rs);

	$rs = mysql_query( 'SELECT id FROM actividad WHERE lobo=5 AND estado=0 ORDER BY ID ASC LIMIT 0,1 ' , $c );
	while($r = mysql_fetch_assoc($rs)) {
		mysql_query( 'UPDATE actividad SET estado=1 WHERE lobo=5 AND estado=0 AND id='.$r['id'], $c );
	}
	mysql_free_result($rs);
	
	mysql_close();
?>